package com.bort.system.controller.api;

import com.bort.system.model.Goods;
import com.bort.system.service.GoodsService;
import com.bort.system.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/client/api")
public class GoodsController {

    @Resource
    GoodsService goodsService;

    @RequestMapping(value = "/getGoods",method = {RequestMethod.GET})
    public Result<List<Goods>> loadSailingGoods(@RequestBody Map<String,Object> params){
        if(params.get("categoryId") != null){
            int cid = Integer.parseInt(params.get("categoryId").toString());
            List<Goods> list = goodsService.loadGoodsByCategoryId(cid);
            return Result.success(list);
        }
        return Result.error("数据有误");
    }

}
